using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore;
using Project_Schedule.Model.Entities;

namespace Project_Schedule.Model;

public class DataDbContext : DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        var configStr =
            $"Data Source={EFAuxiliary.Source};" +
            $"port={EFAuxiliary.Port};" +
            $"Initial Catalog={EFAuxiliary.DataBase};" +
            $"user id={EFAuxiliary.User};" +
            $"password={EFAuxiliary.Pwd};" +
            $"character Set=utf8";

        optionsBuilder.UseMySql(configStr,
            new MySqlServerVersion(new Version(EFAuxiliary.Major, EFAuxiliary.Minor, EFAuxiliary.Build)));
    }

    /// <summary>
    /// 前台用户
    /// </summary>
    public DbSet<System_User>? SystemUsers { get; set; }

    /// <summary>
    /// 后台管理用户
    /// </summary>
    public DbSet<Background_User>? BackgroundUsers { get; set; }
}